Task #M080E

Memory 32 MB Time 2000 ms Complexity 1 %
14

  

Beautiful numbers

A four-digit number \(ABCD \) is beautiful if \(AB^2 + CD^2 \)when divided by \(7\) gives a remainder of \(1\).

For example, the number \(2843 \) is beautiful because

\(28^2 + 43^2 = 2633 = 376 * 7 + 1.\)

You are given \(t\) four-digit numbers, print \(YES \)for each number if the number is beautiful and \(NO\), otherwise


Input:

The first line contains a natural number \(t (1 ≤ t ≤ 10^4)\). Then there are t four-digit numbers.


Output:

If the number is nice, print \(YES\), otherwise \(NO\).


Examples
# input.txt output.txt
1
3
2843
8243
0100
YES
NO
YES
Submit answer
Please, sing in, to complete this action, if you don't have account, you can sign up any moment